package club.caihappy.store.controller;

import club.caihappy.store.entity.Address;
import club.caihappy.store.entity.Order;
import club.caihappy.store.service.IAddressService;
import club.caihappy.store.service.IOrderService;
import club.caihappy.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by DELL on 2022/3/16
 **/
@RestController
@RequestMapping("orders")
public class OrderController extends BaseController {

    @Autowired
    private IOrderService orderService;

    @RequestMapping("create")
    public JsonResult<Order> create(Integer aid, Integer[] cids, HttpSession session) {
        Order data = orderService.create(aid, getUidFromSession(session), getUsernameFromSession(session), cids);
        return new JsonResult<>(OK, data);
    }

}
